package com.lby.redisdemo.config;

import com.lby.redisdemo.bean.SimpleBean;
import com.lby.redisdemo.constant.SimpleMqConstant;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 生产者
 * @ClassName SimpleProducer
 * @Description TODO
 * @Author louby0923
 * @Date 2023/5/30 11:43
 * @Version 1.0
 */
//@Component
public class SimpleProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 消息体为对象。配置MessageConverter为Jackson2JsonMessageConverter即可
     *
     * @param simple
     */
    public void sendOrderMessage(SimpleBean simple) {
        rabbitTemplate.convertAndSend(SimpleMqConstant.HANDLER_OBJECT_QUEUE_NAME, simple);
    }
}
